﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace ProDivingAdmin2salmon14
{
    public class Diver
    {
        public List<Dive> diveList { get; set; }
        public string nationality { get; set; }
        public string fullName { get; set; }
        public string Nr { get; set; }
        public float totalScore { get; set; }
        public int ID { get; set; }
        public bool isDisqualified { get; set; }
        public bool isInjured { get; set; }

        public Diver() 
        {
            this.isDisqualified = false;
            this.isInjured = false;
            this.diveList = new List<Dive>();
            this.totalScore = 0;
            this.ID = 0;
        }

        public Diver(string fullName, string nr, int ID, string nationality, List<Dive> diveList) 
        {
            this.isDisqualified = false;
            this.isInjured = false;
            this.fullName = fullName;
            this.Nr = nr;
            this.ID = ID;
            this.nationality = nationality;
            this.diveList = new List<Dive>(diveList);
        }

        public void CalculateScore() 
        {
            float temp = 0;
            foreach (var dive in diveList) 
            {
               temp += dive.diveScore;
            }
            this.totalScore = temp;
        }

        public void Disqualify()
        {
            this.isDisqualified = true;
            foreach (var dive in this.diveList)
            {
                dive.diveScore = 0;
            }
        }

        public void MarkAsInjured()
        {
            this.isInjured = true;
        }
    }
}
